﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace WizzardTheGame
{
    class Enemy:Character
    {
        private static Vector3 LeftVec = new Vector3(0.5f, 0f, 0f);
        private EnemyState enemy_State;
        private Vector3 moveVector;

        #region Properties

        public Vector3 MoveVector
        {
            get { return moveVector; }
            set { moveVector = value; }
        }

        public EnemyState Enemy_State
        {
            get { return enemy_State; }
            set { enemy_State = value; }
        }

        #endregion

        public enum EnemyState
        {
            patrol, attack
        }

        public Enemy():base()
        {
            Enemy_State = EnemyState.patrol;
            MoveVector = Vector3.Zero;
        }

        public void Drop()
        {
            Random random = new Random();
            for(int i = 0; i < Inventory.Weapons.Count; i++) {
                if (random.Next(10) > 8)
                {
                    if (Inventory.Weapons[i] != null)
                    {
                        GameWorld.getInstance().Items.Add(Inventory.Weapons[i]);
                        GameWorld.getInstance().Drawables.Add(Inventory.Weapons[i]);
                        Inventory.Weapons.Remove(Inventory.Weapons[i]);
                    }
                }
            }
        }

        public override void Update()
        {
            if (Enemy_State == EnemyState.patrol)
            {
                MoveVector = LeftVec;
            }
            base.Update();
            Position += MoveVector;

            //Hvis den er død
            if (CurrentHP < 1)
            {
                IsAlive = false;
                Drop();
                GameWorld.getInstance().Enemies.Remove(this); //måske
                GameWorld.getInstance().Drawables.Remove(this); //måske
            }
        }

        protected override void Attack()
        {
            Enemy_State = EnemyState.attack;
        }
    }
}